<template>
  <div ref="editorDom"></div> 
</template>

<script>
import Editor from "wangeditor"

export default {
  name: "Editor",
  props: {
    value:{type:String}
  },
  watch: {
    value: {
      handler(newValue) {
        this.editor.txt.html(newValue);
      }
    }
  },
  mounted() {
    this.initEditor();
  },
  methods: {
    initEditor() {
      this.editor = new Editor(this.$refs.editorDom);
      this.editor.customConfig.onchange = html => {
        this.$emit("update:content",html);
      };
      this.editor.create();
    },
    clearTxt() {
      this.editor.txt.clear();
    }
  }
}
</script>

<style lang="less" scoped>

</style>